package com.neusoft.bootssm.controller;

import com.neusoft.bootssm.domain.Items;
import com.neusoft.bootssm.service.ItemSerice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(value = "",tags = {"用户信息接口"})
@RestController
public class ItemsController {

    @Autowired
    private ItemSerice serice;


    @ApiOperation(value = "查询商品信息",notes="这是用户信息接口，包含增删改查业务接口")
    @ApiImplicitParam(name = "id",value = "用户id",paramType = "path",dataType = "Integer")
    @GetMapping("/getItems.do/{id}")
    public Items getItems(@PathVariable Integer id)
    {
        return serice.selectByPrimaryKey(id);
    }


    @ApiOperation(value = "查询所有商品信息",notes="这是用户信息接口，包含增删改查业务接口")
    @ApiImplicitParam(name = "pageNo",value = "页码",paramType = "path",dataType = "Integer")
    @GetMapping("/getAll_Items.do/{pageNo}")
    public List<Items> getItems01(@PathVariable Integer pageNo)
    {
        return serice.queryAll();
    }


    @ApiOperation(value = "添加商品信息",notes="注意事项")
    @ApiImplicitParam(dataType = "Items",name = "items",value = "用户信息",required = true)
    @PostMapping(value = "/add_items.do",produces = {"application/json;charset=UTF-8"})
    public String testPost(@RequestBody Items items){
        serice.add_item(items);
        return "success";
    }

    @ApiIgnore
    public String testIgnore(){
        return "success";
    }
}
